
const {woker,quxiaogongdan,deleteorder} = require("../../../util/api")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    delid:"",
    id:"",
    isShow: true,
    memberId:"",
    wokerlist:[],
    workStatus:"4",
    currentTab: "4"
  },
  quxiaoorder(e){
    this.setData({
      id:e.currentTarget.dataset.id
    })
    let p={
      id:this.data.id
    }
    console.log(p)
    quxiaogongdan(p).then(res=>{
      console.log(res)
      if(res.code==200){
        wx.showToast({
          title: '已取消',
          icon: 'success',
          duration: 2000
        })
        this.onLoad()
      }
      
    })

  },
  del(e){

    this.setData({
      id:e.currentTarget.dataset.id
    })
    let p={
      id:this.data.id
    
    }
    deleteorder(p).then(res=>{
      
      this.onLoad()
    })
    
    

  },

  add(){
    wx.navigateTo({
      url: '/pages/addbaoxiu/addbaoxiu',
    })
  },
  tabNav(e) { 
    this.setData({
      currentTab:e.currentTarget.dataset.current,
      memberId:wx.getStorageSync('memberId')
    })  
    let p = {
      memberId:this.data.memberId,
      workStatus:this.data.currentTab

    }
   
    woker(p).then(res=>{
      for(let i=0;i< res.data.length;i++){
        let arr=[];
        arr= res.data[i].workImgs.split(",")
        res.data[i].arr=arr;
      }
      
     console.log(res)
   
      this.setData({
        wokerlist:res.data
        
      })
     })
    
  },
onLoad(){
        this.setData({
          memberId:wx.getStorageSync('memberId')
        })
       let p = {
         memberId:this.data.memberId,
         workStatus:this.data.currentTab

       }
      
       woker(p).then(res=>{

        for(let i=0;i< res.data.length;i++){
          let arr=[];
          arr= res.data[i].workImgs.split(",")
          res.data[i].arr=arr;
        }
        
        console.log(res)
         this.setData({
           wokerlist:res.data
         })
        })
       


 },
  
     



    
onshow(){





    }




    
    
    
    
    } )
